#ifndef BOARD_H
#define BOARD_H

#include "IChessView.h"
#include "ChessGuiDefines.h"
#include "chesspiece.h"
#include <vector>
#include <string>
#include "b_bishop.h"
#include "b_king.h"
#include "b_knight.h"
#include "b_pawn.h"
#include "b_queen.h"
#include "b_rook.h"
#include "nothing.h"
#include "move.h"

class Board {
public:
	IChessView * myView;
	std::vector <ChessPiece *> piecesOnBoard;

	bool blackIsInCheckmate;
	bool whiteIsInCheckmate;
	bool blackIsInCheck;
	bool whiteIsInCheck;
	bool stalemate;

	bool willDoCastle;
	bool whiteKingMoved;
	bool whiteRRookMoved;
	bool whiteLRookMoved;
	bool blackKingMoved;
	bool blackRRookMoved;
	bool blackLRookMoved;

	bool lastWasDoublePawn;
	Cell lastDoublePawn;
	bool canDoEnPassant;


	std::vector<Move> moveHistory;

	Board();
	~Board();

	void StartBoard();
	void setView(IChessView * view);
	void PlaceAllPieces();
	void PlacePiece(ChessPiece * piece);
	ChessPiece * getPieceAt(int row, int col);
	void movePiece(int row, int col, int endrow, int endcol);
	void highlightCell(int row , int col);
	void unhighlightAll();
	void unhighlightCell(Cell c);
	void removeAllPieces();
	int getPiecePosAt(int row, int col);
	void KillPiece(int row, int col);
	bool hasEnemy(Color attacker , int row , int col);
	bool hasTeamate(Color attacker, int row, int col);
	bool hasAnyPiece(int row, int col);
	void ClearAllPieces();
	void moveTestPiece(int row, int col, int endrow, int endcol);
	Cell findEnemyKing(ChessPiece *p);
	Cell findTeamKing(ChessPiece *p);
	Cell findKing(Color color);
	bool undoOneMove();
	ChessPiece * getKillPiece(Move m);
	void UnPawnPro(Move m);
	ChessPiece * getStartPiece(Move m);
	void UnCastle(Move m);

        std::string printMoveHistory();
        void checkLoadedCastleMoves();
        void checkLastWasDoublepawn();
};

#endif // BOARD_H
